package game;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Menu {
    private JFrame frame;
    
    public Menu() {
        frame = new JFrame("菜单");
        frame.setSize(250, 320);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//按叉整个GUI结束
        frame.setLayout(new BorderLayout());
        
        //创建图片
        ImageIcon originalIcon = new ImageIcon("D:\\图片\\Saved Pictures\\ball.jpg"); //图片的路径
        Image scaledImage = originalIcon.getImage().getScaledInstance(250, 250, Image.SCALE_SMOOTH);
        ImageIcon scaledIcon = new ImageIcon(scaledImage);
        JLabel imageLabel = new JLabel(scaledIcon);
    
        //创建按钮面板
        JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
        JButton registerButton = new JButton("注册");
        JButton loginButton = new JButton("登录");
    
        //注册按钮点击事件处理
        registerButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                SignUp.runSignUp();
            }
        });
    
        //登录按钮点击事件处理
        loginButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                SignIn.runSignIn();
            }
        });
    
        buttonPanel.add(registerButton);
        buttonPanel.add(loginButton);
    
        frame.add(imageLabel, BorderLayout.CENTER);
        frame.add(buttonPanel, BorderLayout.SOUTH);
    
        frame.setVisible(true);
        //欢迎
        welcome();
    }
    public static void welcome(){//弹出欢迎框
        JFrame frame=new JFrame("欢迎");
        JOptionPane.showMessageDialog(frame, "欢迎");
    }
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new Menu();
            }
        });
    }
}